package com.yunzone.cloud.modules.service.impl;

import cn.hutool.core.util.IdUtil;
import com.yunzone.cloud.modules.service.MessageProviderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.MessageChannel;
import javax.annotation.Resource;

@EnableBinding(Source.class)//定义消息的推送管道
@Slf4j
public class MessageProviderServiceImpl implements MessageProviderService {
    @Resource
    private MessageChannel  output;//消息发送管道

    @Override
    public String send() {
        String serial= IdUtil.randomUUID();
        output.send(MessageBuilder.withPayload(serial).build());
        log.info("生成流水号：{}",serial);
        return serial;
    }
}
